<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ToolTip</title>
    <script type="text/javascript" src="../../frame/echarts/echarts.min.js"></script>
    <style>
        div{
            display: inline-block;
        }
    </style>
</head>
<body>
<div id="barCross" style="width: 600px;height:400px;"></div>
<div id="barLine" style="width: 600px;height:400px;"></div>
<div id="barLineColor" style="width: 600px;height:400px;"></div>
<div id="barShadow" style="width: 600px;height:400px;"></div>
<div id="barShadowColor" style="width: 600px;height:400px;"></div>
<div id="pie" style="width: 600px;height:400px;"></div>

<script>
    barCross();
    barLine();
    barShadow();
    pie();
    barLineColor();
    barShadowColor();
    function barCross() {
        var myChart = echarts.init(document.getElementById("barCross"));
        // 指定图表的配置项和数据
        var option = {
            title: {
                text: 'ECharts 矩形图-十字准星指示器'
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    crossStyle: {
                        color: '#999'
                    }
                }
            },
            legend: {
                data:['销量']
            },
            xAxis: {
                data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
            },
            yAxis: {},
            series: [{
                name: '销量',
                type: 'line',
                data: [5, 20, 36, 10, 10, 20]
            }]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    }
    function barLine() {
        var myChart = echarts.init(document.getElementById("barLine"));
        // 指定图表的配置项和数据
        var option = {
            title: {
                text: 'ECharts 矩形图-直线指示器'
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'line'
                }
            },
            legend: {
                data:['销量']
            },
            xAxis: {
                data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
            },
            yAxis: {},
            series: [{
                name: '销量',
                type: 'line',
                data: [5, 20, 36, 10, 10, 20]
            }]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    }
    function barLineColor() {
        var myChart = echarts.init(document.getElementById("barLineColor"));
        // 指定图表的配置项和数据
        var option = {
            title: {
                text: 'ECharts 线形图-直线指示器-带颜色的'
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'line',
                    lineStyle:{
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color: 'red' // 0% 处的颜色
                            }, {
                                offset: 1, color: 'blue' // 100% 处的颜色
                            }],
                            globalCoord: false // 缺省为 false
                        }
                    }
                }
            },
            legend: {
                data:['销量']
            },
            xAxis: {
                data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
            },
            yAxis: {},
            series: [{
                name: '销量',
                type: 'line',
                data: [5, 0, 36, 10, 10, 20]
            }]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    }
    function barShadow() {
        var myChart = echarts.init(document.getElementById("barShadow"));
        // 指定图表的配置项和数据
        var option = {
            title: {
                text: 'ECharts 矩形图-阴影指示器'
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                }
            },
            legend: {
                data:['销量']
            },
            xAxis: {
                data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
            },
            yAxis: {},
            series: [{
                name: '销量',
                type: 'line',
                data: [5, 20, 36, 10, 10, 20]
            }]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    }
    function barShadowColor() {
        var myChart = echarts.init(document.getElementById("barShadowColor"));
        // 指定图表的配置项和数据
        var option = {
            title: {
                text: 'ECharts 矩形图-阴影指示器-带颜色'
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow',
                    shadowStyle:{
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color: 'red' // 0% 处的颜色
                            }, {
                                offset: 1, color: 'blue' // 100% 处的颜色
                            }],
                            globalCoord: false // 缺省为 false
                        }
                    }
                }
            },
            legend: {
                data:['销量']
            },
            xAxis: {
                data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
            },
            yAxis: {},
            series: [{
                name: '销量',
                type: 'line',
                data: [5, 20, 36, 10, 10, 20]
            }]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    }
    function pie() {
        var myChart = echarts.init(document.getElementById("pie"));
        // 指定图表的配置项和数据
        var option = {
            title: {
                text: 'ECharts 饼图-模块指示器'
            },
            tooltip: {
                trigger: 'item',
                axisPointer: {
                    type: 'shadow'
                }
            },
            series : [
                {
                    name: '访问来源',
                    type: 'pie',
                    radius: '55%',
                    data:[
                        {value:235, name:'视频广告'},
                        {value:274, name:'联盟广告'},
                        {value:310, name:'邮件营销'},
                        {value:335, name:'直接访问'},
                        {value:400, name:'搜索引擎'}
                    ]
                }
            ]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    }
</script>
</body>
</html>